/**
 * Chic Core - 前端常用工具函数库
 * 专为Vue项目开发设计
 */

// 导入所有工具模块
import * as dateUtils from './utils/date';
import * as stringUtils from './utils/string';
import * as arrayUtils from './utils/array';
import * as objectUtils from './utils/object';
import * as validateUtils from './utils/validate';
import * as storageUtils from './utils/storage';
import * as domUtils from './utils/dom';
import * as formatUtils from './utils/format';
import * as fileUtils from './utils/file';
import * as requestUtils from './utils/request';
import * as treeUtils from './utils/tree';
import * as httpUtils from './utils/http';
import * as swaggerUtils from './utils/swagger';
import * as copyUtils from './copy';
import * as jsonFormatUtils from './jsonFormat';

// 导出所有工具函数
export {
  // 日期工具
  dateUtils,
  // 字符串工具
  stringUtils,
  // 数组工具
  arrayUtils,
  // 对象工具
  objectUtils,
  // 验证工具
  validateUtils,
  // 存储工具
  storageUtils,
  // DOM工具
  domUtils,
  // 格式化工具
  formatUtils,
  // 文件工具
  fileUtils,
  // 请求控制工具
  requestUtils,
  // 树结构工具
  treeUtils,
  // HTTP请求工具
  httpUtils,
  // Swagger工具
  swaggerUtils,
  // 复制工具
  copyUtils,
  // JSON格式化工具
  jsonFormatUtils,
};

// 导出具体函数（按需导入）
export {
  // 日期工具
  formatDate,
  getRelativeTime,
  isToday,
  isYesterday,
  getDateRange,
  getDaysBetween,
} from './utils/date';

export {
  // 字符串工具
  capitalize,
  camelCase,
  kebabCase,
  snakeCase,
  truncate,
  trim,
  randomString,
  isEmpty as isEmptyString,
  isEmail,
  isPhone,
  isUrl,
  template,
} from './utils/string';

export {
  // 数组工具
  unique,
  uniqueBy,
  groupBy,
  sortBy,
  paginate,
  flatten,
  intersection,
  difference,
  union,
  shuffle,
  sum,
  average,
} from './utils/array';

export {
  // 对象工具
  deepClone,
  merge,
  get,
  set,
  unset,
  isEmpty as isEmptyObject,
  invert,
  pickBy,
  pick,
  omit,
  isEqual,
} from './utils/object';

export {
  // 验证工具
  isEmpty as isEmptyValue,
  isNumber,
  isString,
  isArray,
  isObject,
  isFunction,
  isEmail as isEmailValid,
  isPhone as isPhoneValid,
  isUrl as isUrlValid,
  isIdCard,
  isLength,
  isRange,
  isMatch,
  validatePassword,
  validateForm,
} from './utils/validate';

export {
  // 存储工具
  setLocalStorage,
  getLocalStorage,
  removeLocalStorage,
  clearLocalStorage,
  setSessionStorage,
  getSessionStorage,
  removeSessionStorage,
  clearSessionStorage,
  StorageManager,
  localStore,
  sessionStore,
} from './utils/storage';

export {
  // DOM工具
  $,
  $$,
  addClass,
  removeClass,
  toggleClass,
  hasClass,
  setStyle,
  getStyle,
  getOffset,
  scrollTo,
  debounce,
  throttle,
  on,
  off,
  once,
  trigger,
  isInViewport,
  getParents,
  closest,
} from './utils/dom';

export {
  // 格式化工具
  formatNumber,
  formatCurrency,
  formatFileSize,
  formatPercentage,
  formatPhone,
  formatIdCard,
  formatBankCard,
  formatTimestamp,
  formatJSON,
  formatHTML,
  formatUrlParams,
  parseUrlParams,
} from './utils/format';

export {
  // 文件工具
  downloadFile,
  downloadFileFromUrl,
  downloadTextFile,
  downloadJSONFile,
  downloadCanvasAsImage,
  uploadFile,
  uploadFiles,
  previewFile,
  previewImage,
  validateFile,
  getFileExtension,
  getMimeType,
  createFileDropZone,
  selectFiles,
} from './utils/file';

export {
  // 请求控制工具
  deduplicateRequest,
  cachedRequest,
  controlledRequest,
  createRequestDeduplicator,
  createLRUCache,
  createConcurrencyController,
  withRetry,
  withTimeout,
  withCache,
  batchRequest,
  queueRequest,
  RequestDeduplicator,
  LRUCache,
  ConcurrencyController,
  requestDeduplicator,
  lruCache,
  concurrencyController,
} from './utils/request';

export {
  // 树结构工具
  arrayToTree,
  treeToArray,
  findTreeNode,
  findTreeNodePath,
  filterTree,
  mapTree,
  traverseTree,
  getTreeDepth,
  getTreeNodeCount,
  getTreeLeaves,
  getTreeNodeLevel,
  sortTree,
  flattenTree,
  validateTree,
} from './utils/tree';

export {
  // HTTP请求工具
  createHttpClient,
  createDefaultHttpClient,
  httpClient,
  HttpConfig,
  HttpClient,
  HTTP_STATUS,
  ERROR_TYPES,
} from './utils/http';

export {
  // 复制工具
  copyToClipboard,
  copySelectedText,
  createSelectionCopyTip,
} from './copy';

export {
  // JSON格式化工具
  standardizeApiResponse,
  formatApiData,
} from './jsonFormat';

// 默认导出（包含所有工具）
const ChicCore = {
  // 日期工具
  ...dateUtils,
  // 字符串工具
  ...stringUtils,
  // 数组工具
  ...arrayUtils,
  // 对象工具
  ...objectUtils,
  // 验证工具
  ...validateUtils,
  // 存储工具
  ...storageUtils,
  // DOM工具
  ...domUtils,
  // 格式化工具
  ...formatUtils,
  // 文件工具
  ...fileUtils,
  // 请求控制工具
  ...requestUtils,
  // 树结构工具
  ...treeUtils,
  // HTTP请求工具
  ...httpUtils,
  // Swagger工具
  ...swaggerUtils,
  // 复制工具
  ...copyUtils,
  // JSON格式化工具
  ...jsonFormatUtils,
};

export default ChicCore;
